﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

//buddy
using Zeta;
using Zeta.Common;
using Zeta.CommonBot;
using Zeta.Common.Plugins;
using Zeta.Internals;
using Zeta.Internals.Actors;
using Zeta.Internals.Service;

namespace BossHog.ProfileBuilder
{
    public class GameParamsElement : IProfileChildElement
    {
        public string quest { get; set; }
        public string step { get; set; }
        public string act { get; set; }
        public string difficulty { get; set; }
        public string resumeFromSave { get; set; }
        public string isPrivate { get; set; }
        public string numGames { get; set; }
        public override string ToString() 
        {
            return string.Format("<GameParams quest=\"{0}\" step=\"{1}\" act=\"{2}\" difficulty=\"{3}\" resumeFromSave=\"{4}\" isPrivate=\"{5}\" numGames=\"{6}\"  />", new object[] { quest, step, act, difficulty, resumeFromSave, isPrivate, numGames });
        }

        public void Write(System.Xml.XmlTextWriter w)
        {
            Type t = this.GetType();
            System.Reflection.PropertyInfo[] pi = t.GetProperties();

            w.WriteStartElement(t.Name.Replace("Element", ""));

            if (null != pi && pi.Length > 0)
            {
                for (int i = 0; i < pi.Length; i++)
                {

                    object o = null;
                    try
                    {
                        o = pi[i].GetValue(this, new object[] { });
                    }
                    catch (Exception ex) { Logging.Write(LogLevel.Verbose, "[BossHog] Reflaction Error: " + ex.ToString()); }

                    if (null != o)
                    {
                        string sTmp = o.ToString();

                        if (!string.IsNullOrEmpty(sTmp) && !string.IsNullOrWhiteSpace(sTmp))
                        {
                            w.WriteStartAttribute(pi[i].Name);
                            w.WriteValue(sTmp);
                            w.WriteEndAttribute();
                        }
                    }
                }
            }
            w.WriteEndElement();
        }

    }
}
